﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SocialShare.DataAccessLayer;
using SocialShare.BusinessLogicLayer;
using SocialShare.BusinessEntities;
using SocialShare.BLL;

namespace SocialShare.DAL.Facades
{
    [System.ComponentModel.DataObject(true)]
    public class ForumFacade
    {
        private SocailShare_Forum_MessagesBLL bll = null;

        private SocialShare_Forum_CategoriesBLL bllCat=null;

        public ForumFacade() { }

        private SocailShare_Forum_MessagesBLL MessageInstance
        {
            get
            {
                if (bll == null)
                {
                    return bll = new SocailShare_Forum_MessagesBLL();
                }
                else
                {
                    return bll;
                }
            }
            
        }

        private SocialShare_Forum_CategoriesBLL MessageCategoryInstance
        {
            get
            {
                if (bllCat == null)
                {
                    return bllCat = new SocialShare_Forum_CategoriesBLL();
                }
                else
                {
                    return bllCat;
                }
            }

        }

        #region Utility Functions       

        public List<SocialShare_Forum_Categories> GetAllForumCategories()
        {
            return this.MessageCategoryInstance.GetAllSocialShare_Forum_Categories();
        }

        public virtual int CreateNewForum_Messages(SocailShare_Forum_Messages forumMessage)
        {
            return this.MessageInstance.CreateNewSocailShare_Forum_Messages(forumMessage);
        }

        public virtual int CreateNewForumCategory(SocialShare_Forum_Categories forumcategory)
        {
            return this.MessageCategoryInstance.CreateNewSocialShare_Forum_Categories(forumcategory);
        }

        public SocailShare_Forum_Messages LoadParentPost(Int32 postId)
        {
            return this.MessageInstance.LoadParentPost(postId);
        }

        public SocailShare_Forum_Messages GetForumMessagesByPostId(int postId)
        {
            return this.MessageInstance.GetSocailShare_Forum_MessagesByPostId(postId);
        }

        public void UpdateForumMessages(SocailShare_Forum_Messages post)
        {
            this.MessageInstance.UpdateSocailShare_Forum_Messages(post);
        }

        public void UpdateForumCategory(SocialShare_Forum_Categories forumcategory)
        {
            this.MessageCategoryInstance.UpdateSocialShare_Forum_Categories(forumcategory);
        }

        #endregion

        #region Component Functions

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllActiveForumMessages(Int32? categoryId, Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32))
        {
            return this.MessageInstance.GetAllActiveForumMessages(categoryId, startRowIndex, maximumRows);
        }

        public Int32 GetTotalCountAllActiveForumMessages(Int32? categoryId, Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32))
        {
            return this.MessageInstance.GetTotalCountAllActiveForumMessages(categoryId, startRowIndex, maximumRows);
        }

        public Int32 GetTotalCountActiveForumMessagesByCategory(Int32? categoryId, Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32))
        {
            return this.MessageInstance.GetTotalCountActiveForumMessagesByCategory(categoryId, startRowIndex, maximumRows);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllActiveForumMessagesByCategory(Int32? categoryId, Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32))
        {
            return this.MessageInstance.GetAllActiveForumMessagesByCategory(categoryId, startRowIndex, maximumRows);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllActiveForumMessagesByID(Int32 postId)
        {
            return this.MessageInstance.GetAllActiveForumMessagesByID(postId);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllForumMessages(Int32? categoryId)
        {
            return this.MessageInstance.GetAllForumMessages(categoryId);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllForumMessagesByID(Int32 postId)
        {
            return this.MessageInstance.GetAllForumMessagesByID(postId);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<MessageCategory> GetAllActiveForumCategory()
        {
            return this.MessageInstance.GetAllActiveForumCategory();
        }

        public SocialShare_Forum_Categories GetForumCategoryById(Int32 categoryId)
        {
            return this.MessageCategoryInstance.GetSocialShare_Forum_CategoriesByCategoryId(categoryId);
        }


        public Int32 GetAllForumMessages()
        {
            return this.MessageInstance.GetAllForumMessages(null).Count;
        }


        public List<CountReport> GetTotalPostsByMonth()
        {
            return this.MessageInstance.GetTotalPostsByMonth();
        }


        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public List<Message> GetAllPostsByMember(Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32), String UserID = default(String))
        {
            return this.MessageInstance.GetAllPostsByMember(startRowIndex, maximumRows, UserID);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public Int32 GetTotalCountAllPostsByMember(Int32 startRowIndex = default(Int32), Int32 maximumRows = default(Int32), String UserID = default(String))
        {
            return this.MessageInstance.GetTotalCountAllPostsByMember(startRowIndex, maximumRows, UserID);
        }


        #endregion  
     
    }
}
